package com.huluobo.a2207parkdemo

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.bean.ShopBean
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

/**
 *  Created by LC on 2024/11/15.
 */
@HiltViewModel
class MainViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getAllNewsSuccess by lazy { MutableLiveData<String>() }
    fun getAllNews(body: RequestBody) {
        executeNetwork(
            { apiService.getAllNews(body) },
            getAllNewsSuccess::postValue
        )
    }

    val getGoodsSuccess by lazy { MutableLiveData<List<ShopBean>>() }
    fun getGoods(categoryId: Int, currentPage: Int, pageSize: Int) {
        executeNetwork2(
            { apiService.getGoods(categoryId, currentPage, pageSize) },
            getGoodsSuccess::postValue
        )
    }
}